package com.retail.lottery.colalottery.config.mq;

import cn.hutool.json.JSONUtil;
import com.retail.lottery.colalottery.service.OrderCallbackService;
import com.retail.lottery.colalottery.vo.request.OrderCallBackVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@Slf4j
public class OrderCallbackConsumer {

    @Resource
    private OrderCallbackService orderCallbackService;

    //@RabbitListener(queues = OrderCallbackProductConfig.ORDER_CALLBACK_QUEUE)
    public void msg(String msg) {
        log.info("rabbitMqConsumer:{}", msg);
        try {
            OrderCallBackVo orderCallBackVo = JSONUtil.toBean(msg, OrderCallBackVo.class);
            orderCallbackService.orderDataPostBack(orderCallBackVo);
        } catch (Exception e) {
            log.error("rabbitMqConsumer ERROR:{}", msg, e);
        }
    }
}
